//
//  APMBannerView.h
//  APMBanner
//
//  Created by apang on 2022/9/12.
//

#import <UIKit/UIKit.h>
#import <APMBannerView/APMBannerViewCell.h>
NS_ASSUME_NONNULL_BEGIN

/// Banner view scroll position
typedef NS_ENUM(NSInteger, APMBannerViewScrollPosition) {
    /// Banner view scroll position left
    APMBannerViewScrollPositionLeft     =   0,
    /// Banner view scroll position right
    APMBannerViewScrollPositionRight    =   1
};

@protocol APMBannderViewDelegate;

/// custom banner view use UICollectionView
@interface APMBannerView : UIView

///  dataSource and delegate
@property (nonatomic, weak) id<APMBannderViewDelegate> delegate;

/// default is YES
@property (nonatomic, assign) BOOL autoScrollEnable;

/// default 1.5
@property (nonatomic, assign) NSTimeInterval autoScrollDelayDuration;

/// banner scroll position
@property (nonatomic, assign) APMBannerViewScrollPosition scrollPosition;

/// default YES.
@property (nonatomic, assign) BOOL scrollEnable;

/// see UICollectionView registerClass:forCellWithReuseIdentifier:
/// @param  cellClass   APMBannerViewCell or it's subclass
/// @param  identifier  cell identifier
- (void)registerClass:(nullable Class)cellClass forCellWithReuseIdentifier:(NSString *)identifier;

/// see UICollectionView registerNib:forCellWithReuseIdentifier:
/// @param  nib   APMBannerViewCell or it's subclass nib
/// @param  identifier  cell identifier
- (void)registerNib:(nullable UINib *)nib forCellWithReuseIdentifier:(NSString *)identifier;

/// see UICollectionView dequeueReusableCellWithReuseIdentifier:forIndexPath:
/// @param  identifier  cell identifier
/// @param  indexPath  indexPath
/// @return APMBannerViewCell or it's subclass obj
- (APMBannerViewCell *)dequeueReusableCellWithReuseIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath *)indexPath;

/// reload data
- (void)reloadData;
@end

/// banner dataSource and delegate
@protocol APMBannderViewDelegate <NSObject>
/// return banner all counts
/// @param  bannerView  banner
/// @return banner
- (NSInteger)numberOfItemsInBannerView:(APMBannerView *)bannerView;
/// return  banner cell
/// @param  bannerView banner
/// @param  indexPath   collection indexPath
/// @param  itemIndex   data index
/// @return banner cell
- (APMBannerViewCell *)bannerView:(APMBannerView *)bannerView cellForItemAtIndexPath:(NSIndexPath *)indexPath itemIndex:(NSInteger)itemIndex;
@optional
/// banner selet
/// @param  bannerView  banner
/// @param  index   data index
- (void)bannerView:(APMBannerView *)bannerView didSelectItemAtIndex:(NSInteger)index;
/// banner did show
/// @param  bannerView  banner
/// @param  index   data index
- (void)bannerView:(APMBannerView *)bannerView didShowItemAtIndex:(NSInteger)index;
@end
NS_ASSUME_NONNULL_END
